<template>
  <div class="change">
    <div class="change-header">
      <van-nav-bar
        class="change-bar"
        title="修改密码"
        left-arrow
        @click-left="back"
      />
    </div>

    <!-- 输入旧密码 -->
    <van-field
      v-model="oldPassword"
      type="password"
      placeholder="请输入旧密码"
      label="旧密码"
    />
    <!-- 输入新密码 -->
    <van-field
      v-model="newPassword"
      type="password"
      placeholder="请输入新密码"
      label="新密码"
    />

    <div class="change-btn2">
      <van-button type="primary" @click="changePassword()">确认修改</van-button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      oldPassword: "",
      newPassword: "",
      uid_1:''
    };
  },
  mounted(){
this.uid_1=localStorage.getItem('uid')
  },
  methods: {
    back() {
      this.$router.push("/my");
    },
    changePassword(){
      this.$http.post('/user/updatePwd',{
        oldPassword:this.oldPassword,newPassword:this.newPassword,uid: this.uid_1
      }).then(res=>{
        console.log(res)
      })
    }
  },
};
</script>

<style>
.change {
  position: relative;
}

.change-btn2 {
  position: absolute;
  left: 13px;
}
.change-btn2 button {
  width: 350px;
  text-align: center;
}
.change-bar {
  background: #07c060;
}
.van-nav-bar__title {
  color: white;
}
</style>